package com.hup.minicontroller.common.bluetooth;

import android.bluetooth.BluetoothServerSocket;
import android.bluetooth.BluetoothSocket;

import java.io.IOException;

/**
 * @author hugan
 * @date 2021/5/14
 */
public abstract class BtUtil {

    public static BluetoothServerSocket closeSilently(BluetoothServerSocket serverSocket) {
        if (serverSocket == null) return null;
        try {
            serverSocket.close();
        } catch (IOException ignored) {
        }
        return null;
    }

    public static void closeSilently(BluetoothSocket socket) {
        if (socket != null && socket.isConnected()) {
            try {
                socket.close();
            } catch (IOException ignored) {
            }
        }
    }

}
